home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / sound / rsynth22.zip / DEF_PARS.C < prev    next >
Text File  |  1996-08-06  |  3KB  |  123 lines

  1. #include <config.h>
  2. /* $Id: def_pars.c,v 1.13 1994/11/08 13:30:50 a904209 Exp a904209 $
  3.  */
  4. char *def_pars_id = "$Id: def_pars.c,v 1.13 1994/11/08 13:30:50 a904209 Exp a904209 $";
  5. #include <stdio.h>
  6. #include <useconfig.h>
  7. #include <math.h>
  8. #include "proto.h"
  9. #include "getargs.h"
  10. #include "nsynth.h"
  11. #include "hplay.h"
  12. #define USE_RC_FILE 1 
  13.  
  14.  
  15. klatt_global_t klatt_global;
  16.  
  17. /* default values for pars array from .doc file */
  18. klatt_frame_t def_pars =
  19. {
  20. #include "pars.def"
  21. };
  22.  
  23. #ifdef USE_RC_FILE
  24.  
  25. #define RC_FILE "/sayrc"
  26.  
  27. /* Based on an idea by 
  28.  
  29.    John Cartmill   -  cartmill@wisconsin.nrlssc.navy.mil 
  30.  
  31.    The ability to read the user's  .sayrc file 
  32.    ( which has the same format as  the pars.def file) 
  33.  
  34.    Not enabled by default as I don't have one other than 
  35.    pars.def! to test it on and it does not handle comments  
  36.  
  37.  */
  38.  
  39. static void
  40. read_rc_file(void)
  41. {
  42.  char *home = getenv("HOME");
  43.  if (home)
  44.   {
  45.    char *path = malloc(strlen(home) + strlen(RC_FILE) + 1);
  46.    if (path)
  47.     {
  48.      FILE *f = fopen(strcat(strcpy(path, home), RC_FILE), "r");
  49.      if (f)
  50.       {
  51.        char string[256];
  52.        int i, value;
  53.        union 
  54.           {
  55.             klatt_frame_t def_pars;
  56.             long array[NPAR];
  57.           } pars;
  58.  
  59.        for (i = 0; i < NPAR; ++i)
  60.         {
  61.          char comment[256];
  62.  
  63.          fgets(string, sizeof(string), f);
  64.          /* value = atoi(string); */
  65.          sscanf(string," %d, /* %s",&value, comment);
  66.          pars.array[i] = value;
  67.         }
  68.        def_pars = pars.def_pars;
  69.        fclose(f);
  70.       }
  71.      free(path);
  72.     }
  73.   }
  74. }
  75.  
  76. #endif
  77.  
  78. int
  79. init_synth(argc, argv)
  80. int argc;
  81. char *argv[];
  82. {
  83.  double mSec_per_frame = 10;
  84.  int impulse = 0;
  85.  int casc = 0;
  86.  klatt_global.samrate = samp_rate;
  87.  klatt_global.quiet_flag = TRUE;
  88.  klatt_global.glsource = NATURAL;
  89.  klatt_global.f0_flutter = 0;
  90.  
  91. #ifdef USE_RC_FILE
  92.  read_rc_file();
  93. #endif
  94.  
  95.  argc = getargs("Synth paramters",argc, argv,
  96.                 "q", NULL, &klatt_global.quiet_flag, "Quiet - minimal messages",
  97.                 "I", NULL, &impulse,                 "Impulse glottal source",
  98.                 "c", "%d", &casc,                    "Number cascade formants",
  99.                 "F", "%d", &klatt_global.f0_flutter, "F0 flutter",
  100.                 "f", "%lg", &mSec_per_frame,         "mSec per frame",
  101.                 "t", "%d", &def_pars.TLTdb,          "Tilt dB",
  102.                 "x", "%d", &def_pars.F0hz10,         "Base F0 in 0.1Hz",
  103.                 NULL);
  104.  
  105.  if (casc > 0)
  106.   {
  107.    klatt_global.synthesis_model = CASCADE_PARALLEL;
  108.    klatt_global.nfcascade = casc;
  109.   }
  110.  else
  111.   klatt_global.synthesis_model = ALL_PARALLEL;
  112.  
  113.  if (impulse)
  114.   klatt_global.glsource = IMPULSIVE;
  115.  
  116.  klatt_global.nspfr = (klatt_global.samrate * mSec_per_frame) / 1000;
  117. #ifdef HAVE_NONSTDARITH
  118.  /* turn off strict IEEE compliance in favour of speed */
  119.  nonstandard_arithmetic();
  120. #endif
  121.  return argc;
  122. }
  123.